<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('oss设置')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-tradeset-edit" th:object="${sysTradeset}">
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">Access Key ID：</label>
                <div class="col-sm-8">
                    <input name="keyid" th:field="*{keyid}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">Access Key Secret：</label>
                <div class="col-sm-8">
                    <input name="keysecret" th:field="*{keysecret}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">Bucket：</label>
                <div class="col-sm-8">
                    <input name="bucket" th:field="*{bucket}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">EndPoint：</label>
                <div class="col-sm-8">
                    <input name="endpoint" th:field="*{endpoint}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-offset-5 col-sm-10">
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            </div>
        </div>
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">是否启用：</label>
                <div class="col-sm-8">
                    <input type="checkbox" id="state" th:checked="${sysTradeset.state == 1 ? true : false}">启用阿里云OSS存储
                </div>

            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var prefix = ctx + "system/ossset";
    $("#form-tradeset-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $('#form-tradeset-edit').serializeArray();
            var state = $("input[id='state']").is(':checked') == true ? 1 : 0;
            data.push({"name": "state", "value": state});
            $.operate.save(prefix + "/edit", data,function(result) {
                layer.msg(result.msg, {
                    icon: $.modal.icon(0),
                    time: 500,
                    shade: [0.1, '#8F8F8F']
                });
            });
        }
    }
</script>
</body>
</html>